home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / CHECKBOX.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  133 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Definition of class TCheckBox. This defines the basic behavior for all check
  8. // boxes.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_CHECKBOX_H)
  11. #define OWL_CHECKBOX_H
  12.  
  13. #if !defined(OWL_BUTTON_H)
  14. # include <owl/button.h>
  15. #endif
  16.  
  17. #if defined(BI_NAMESPACE)
  18. namespace OWL {
  19. #endif
  20.  
  21. class _OWLCLASS TGroupBox;
  22.  
  23. //
  24. // Checkbox flags indicating check state
  25. //
  26. enum {
  27.   BF_CHECKED   = 0x01,
  28.   BF_GRAYED    = 0x02,
  29.   BF_UNCHECKED = 0x00,
  30. };
  31.  
  32. // Generic definitions/compiler options (eg. alignment) preceeding the
  33. // definition of classes
  34. #include <services/preclass.h>
  35.  
  36. //
  37. // class TCheckBox
  38. // ~~~~~ ~~~~~~~~~
  39. class _OWLCLASS TCheckBox : public TButton {
  40.   public:
  41.     TCheckBox(TWindow*        parent,
  42.               int             id,
  43.               const char far* title,
  44.               int x, int y, int w, int h,
  45.               TGroupBox*      group = 0,
  46.               TModule*        module = 0);
  47.  
  48.     TCheckBox(TWindow*   parent,
  49.               int        resourceId,
  50.               TGroupBox* group = 0,
  51.               TModule*   module = 0);
  52.    ~TCheckBox();
  53.  
  54.     void       Check();
  55.     void       Uncheck();
  56.     void       Toggle();
  57.  
  58.     uint       GetCheck() const;
  59.     void       SetCheck(uint check);
  60.  
  61.     TGroupBox* GetGroup() const;
  62.     void       SetGroup(TGroupBox* group);
  63.  
  64.     // Override TWindow virtual member functions
  65.     //
  66.     uint       Transfer(void* buffer, TTransferDirection direction);
  67.  
  68.   protected:
  69.     //  Override TButton's processing so drawable check boxes and radio
  70.     //  buttons work properly
  71.     //
  72.     uint       EvGetDlgCode(MSG far*);
  73.  
  74.     // Child id notification
  75.     //
  76.     void       BNClicked();  // BN_CLICKED
  77.  
  78.     char far*  GetClassName();
  79.  
  80.   public_data:
  81.     TGroupBox* Group;
  82.  
  83.   private:
  84.     // Hidden to prevent accidental copying or assignment
  85.     //
  86.     TCheckBox(const TCheckBox&);
  87.     TCheckBox& operator =(const TCheckBox&);
  88.  
  89.   DECLARE_RESPONSE_TABLE(TCheckBox);
  90.   DECLARE_STREAMABLE(_OWLCLASS, TCheckBox, 1);
  91. };
  92.  
  93. #if defined(BI_NAMESPACE)
  94. } // namespace OWL
  95. #endif
  96.  
  97. // Generic definitions/compiler options (eg. alignment) following the
  98. // definition of classes
  99. #include <services/posclass.h>
  100.  
  101. //
  102. inline void TCheckBox::Check() {
  103.   SetCheck(BF_CHECKED);
  104. }
  105.  
  106. //
  107. inline void TCheckBox::Uncheck() {
  108.   SetCheck(BF_UNCHECKED);
  109. }
  110.  
  111. //
  112. inline TGroupBox* TCheckBox::GetGroup() const {
  113.   return Group;
  114. }
  115.  
  116. //
  117. inline void TCheckBox::SetGroup(TGroupBox* group) {
  118.   Group = group;
  119. }
  120.  
  121. //
  122. inline uint TCheckBox::EvGetDlgCode(MSG far*) {
  123.   return (uint)DefaultProcessing();
  124. }
  125.  
  126. //
  127. inline uint TCheckBox::GetCheck() const {
  128.   PRECONDITION(GetHandle());
  129.   return (uint)CONST_CAST(TCheckBox*, this)->SendMessage(BM_GETCHECK);
  130. }
  131.  
  132. #endif  // OWL_CHECKBOX_H
  133.